package com.app.signing.utils

import android.os.Parcel
import android.os.Parcelable

/**
 * @author wangpeifeng
 * @date 2018/05/08 12:56
 */
data class LocationResult(
    val errorCode: Int,
    val latitude: Double,
    val longitude: Double,
    val errorInfo: String
) : Parcelable {

    constructor(source: Parcel) : this(
            source.readInt(),
            source.readDouble(),
            source.readDouble(),
            source.readString()
    )

    override fun describeContents() = 0

    override fun writeToParcel(
        dest: Parcel,
        flags: Int
    ) = with(dest) {
        writeInt(errorCode)
        writeDouble(latitude)
        writeDouble(longitude)
        writeString(errorInfo)
    }

    companion object {
        @JvmField
        val CREATOR: Parcelable.Creator<LocationResult> = object : Parcelable.Creator<LocationResult> {
            override fun createFromParcel(source: Parcel): LocationResult = LocationResult(source)
            override fun newArray(size: Int): Array<LocationResult?> = arrayOfNulls(size)
        }
    }
}